var protocole = "http";
//var host = "192.168.43.5"
var host = "192.168.43.5"
//var host = "localhost"
//var host = "dev.ulysseroland.fr";
var port = 8080;
var method = "GET";
var typeData = "json";
	
var interactionWebService = {
		infosEtape : function(onResponse, onError, idEtape) {
			requete("Participant/Etape", 
					"idEtape=" + idEtape, 
					onResponse, 
					onError);
		},
		inscriptionPartie: function(onResponse, onError, mdpPartie) {
			requete("Participant/Inscription",
					"mdpEnquete=" + mdpPartie,
					onResponse,
					onError)
		},
		affichagescenario : function(onResponse, onError, mdpPartie) {
			requete("Participant/InfosScenario", 
					"mdpEnquete=" + mdpPartie, 
					onResponse, 
					onError);
		},
		sauvegarderEtape: function(onResponse, onError, reponse, etapeId, equipId) {
			requete("Participant/SauvegarderEtape", 
					"reponse=" + reponse + "&etapeId=" + etapeId + "&equipeId=" + equipId, 
					onResponse, 
					onError);
		},
		prochaineEtapeparEquipe: function(onResponse, onError, equipeId, derniereEtape) {
			requete("Participant/ProchaineEtapeParEquipe", 
					"equipeId=" + equipeId + "&derniereEtape=" + derniereEtape, 
					onResponse, 
					onError);
		}
};
function requete(service, params, onResponse, onErreur) {
	$.ajax({
		url: protocole + "://" + host + ":" + port + "/AndroWeb/" + service + ".php",
		type: method,
        dataType: typeData,
        data: params,
        error: function (jqXHR, textStatus, errorThrown) {
            onErreur(errorThrown);
        },
        success: function (data) {
        	if (data == null || typeof(data.erreur) === 'undefined') {
        		onResponse(data);
        	} else {
        		onErreur(data.erreur);
        	}
        }
    });
}
